// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { game } from "../../../../script/game/control/game";
import { recordType } from "../../../../script/game/model/playerEvent";
import { ListItem } from "../../../../script/util/ListView/ListItem";
import { ListViewAdapter } from "../../../../script/util/ListView/ListViewAdapter";
import { WinBase } from "../../../../script/wins/WinBase";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends WinBase {
    

    @property(ListViewAdapter)
    list: ListViewAdapter = null;

    start () {
        this.showData();
        this.registerEvent("upRecord", () => {
            this.showData();
            this.scheduleOnce(() => { 
                this.list.getComponent(cc.ScrollView).scrollToBottom(0.5);
                this.list.handlerScroll();
            }, 0.8);
        })
    }
    onEnable() {
        this.scheduleOnce(() => { 
            this.list.getComponent(cc.ScrollView).scrollToBottom(0.5);
            this.list.handlerScroll();
        }, 0.8);
    }
    showData() {
        this.scheduleOnce(() => {
            this.list.updateItems(game.recordMgr.getList());
        }, 0.1);
    }
    addData() {
        // this.list.addItem()
    }
    // update (dt) {}
}
